package com.igeek.dao;

import com.igeek.bean.Brand;
import com.igeek.bean.Car;
import com.igeek.db.DataDB;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BrandDao {

    List<Brand> brands= DataDB.getInstance().brands;
    List<Car> cars = DataDB.getInstance().cars;

    //改1
    public String findBrand(int id){
        String a = "";
        for(Brand brand : brands){
            if(brand.getBrandid() == id){
                a = brand.getBname();
            }
        }
        return a;

    }

    //改2
    public int find(int id){
        int b = 0;

        for(Car car : cars){
            if(id == car.getBrandid()){
                b = id;
            }
        }
        return b;
    }

    public void insertBrand(){
        Scanner scanner = new Scanner(System.in);

        System.out.println("输入品牌编号");
        int id = scanner.nextInt();
        System.out.println("输入品牌名称");
        String name = scanner.next();

        System.out.println("输入备注,若没有备注输入无");
        String remark = scanner.next();
        Brand brand = new Brand(name,id,remark);
        brands.add(brand);

    }
}
